package com.example.demo.controller;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.example.demo.dbo.JxrbVideoProcessParam;
import com.example.demo.dbo.VideoProcessParam;
import com.example.demo.util.JsonUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;

import java.util.HashMap;
import java.util.Map;

/**
 * @author: yby
 * @desc:
 * @date: 2024/9/20 14:56
 */
@Slf4j
public class HuaweiController {

    public static void main(String[] args) {
//        String baseUrl = "https://app.nmu.pdmiryun.com/portal";
//        System.out.println(baseUrl.replace("/portal",""));
//
//        String messageBody = "{\"code\":-6,\"data\":{\"url\":[],\"userData\":\"1729568799628016\"},\"msg\":\"file not exit or download failed\",\"taskId\":1729568799628016,\"taskType\":\"record_2_mp4\"}";
//        String messageBody1 = "{\"code\":-6,\"outs\":[],\"data\":{\"url\":\"\",\"userData\":\"1729568799628016\"},\"msg\":\"file not exit or download failed\",\"taskId\":1729568799628016,\"taskType\":\"record_2_mp4\"}";
//        if (messageBody.contains("url\":[]")) {
//            messageBody = messageBody.replace("url\":[]","url\":\"\"");
//        }
//        VideoRet videoRet = JsonUtil.fromJson(messageBody, VideoRet.class);
//        long taskId = Long.valueOf(videoRet.getData().getUserData());
//        String url = videoRet.getData().getUrl();
//
//        long duration = videoRet.getData().getDuration();
//        long size = videoRet.getData().getSize();
//        System.out.println("duration:"+duration);
//        System.out.println("size:"+size);

//        String json = "{\"msg\":\"成功\",\"total\":69,\"list\":[{\"coverImg\":\"https://app-newstest.ceic.com/mam/material/mam/d073b9aa8d058a95f016890f3de43562/ddc4822ad1284921b53e794433c8f7f1/image/2024/10/22/90c4e1571bb6434ab60d3e3d580511ae.jpg\",\"creator\":\"性能测试\",\"creatorId\":\"7a8c70eefde44410b9a7f771250f75a8\",\"duration\":30490,\"format\":\"mp4\",\"height\":1080,\"id\":111111111111,\"size\":44800421,\"title\":\"7d808114e1c80d3daa326b0692cd7cca_raw.mp4\",\"url\":\"https://app-newstest.ceic.com/mam/material/mam/d073b9aa8d058a95f016890f3de43562/2024/10/17/97c3c07ddc0f41fbab3f5553cac976bb.mp4\",\"width\":1920}],\"status\":200}";
//        DGuanUserResourceResp userResourceResp = JsonUtil.fromJson(json, DGuanUserResourceResp.class);
//
//        System.out.println("resp:"+userResourceResp);

        Map<String, Object> headers = new HashMap<>();
        headers.put("Content-Type", "application/json");
        headers.put("sign", "sign");
        headers.put("appId", "appId");
        headers.put("timestamp", System.currentTimeMillis());
        headers.put("token", "token");
        StringBuilder stringBuilder = new StringBuilder("http://localhost");
        stringBuilder.append("?pageNum=").append(1);
        stringBuilder.append("&pageSize=").append(10);
        stringBuilder.append("&userId=" + "11111111");
        stringBuilder.append("&resourceId=" + "222222");
        stringBuilder.append("&resourceType=" + "3333333");
//        log.info("VideoProcessDGuanServiceImpl--->getUserResourceList--->headers:{},stringBuilder：{}", JsonUtil.toJson(headers),JsonUtil.toJson(stringBuilder));

        String json = "{\"msg\":\"成功\",\"total\":107,\"list\":[{\"converImg\":\"https://app-newstest.ceic.com/mam/material/mam/uploadTemp/ad057e84a73847cbb2e169399b49b57a_s.jpg\",\"creator\":\"性能测试\",\"creatorId\":\"7a8c70eefde44410b9a7f771250f75a8\",\"format\":\"jpg\",\"height\":1067,\"id\":\"b1bc09c5a0904d0681873002ba2c02ef\",\"size\":525263,\"title\":\"92866e8d33d045b69a971420a4ff7a0b.jpg\",\"type\":1,\"url\":\"https://app-newstest.ceic.com/mam/material/mam/uploadTemp/ad057e84a73847cbb2e169399b49b57a.jpg\",\"width\":1600},{\"converImg\":\"https://app-newstest.ceic.com/mam/material/mam/uploadTemp/7e89d69d4fdb46bcb686773bfe9b2798_s.jpg\",\"creator\":\"性能测试\",\"creatorId\":\"7a8c70eefde44410b9a7f771250f75a8\",\"format\":\"jpg\",\"height\":1067,\"id\":\"323e1c7d36c94b10acf9c11896d70572\",\"size\":525263,\"title\":\"92866e8d33d045b69a971420a4ff7a0b.jpg\",\"type\":1,\"url\":\"https://app-newstest.ceic.com/mam/material/mam/uploadTemp/7e89d69d4fdb46bcb686773bfe9b2798.jpg\",\"width\":1600},{\"converImg\":\"https://app-newstest.ceic.com/mam/material/mam/uploadTemp/5bea329de8024678b423872bbd3c7626_s.jpg\",\"creator\":\"性能测试\",\"creatorId\":\"7a8c70eefde44410b9a7f771250f75a8\",\"format\":\"jpg\",\"height\":1067,\"id\":\"87876a56614845a79bd4e55cfefb1e06\",\"size\":525263,\"title\":\"92866e8d33d045b69a971420a4ff7a0b.jpg\",\"type\":1,\"url\":\"https://app-newstest.ceic.com/mam/material/mam/uploadTemp/5bea329de8024678b423872bbd3c7626.jpg\",\"width\":1600},{\"converImg\":\"https://app-newstest.ceic.com/mam/material/mam/uploadTemp/ed151441412f46aa981a5d1f7d6db7f4_s.jpg\",\"creator\":\"性能测试\",\"creatorId\":\"7a8c70eefde44410b9a7f771250f75a8\",\"format\":\"jpg\",\"height\":1067,\"id\":\"b4dbd689268b4b3d955f185fca8d8fa7\",\"size\":525263,\"title\":\"92866e8d33d045b69a971420a4ff7a0b.jpg\",\"type\":1,\"url\":\"https://app-newstest.ceic.com/mam/material/mam/uploadTemp/ed151441412f46aa981a5d1f7d6db7f4.jpg\",\"width\":1600},{\"converImg\":\"https://app-newstest.ceic.com/mam/material/mam/uploadTemp/f87d033e870849e48103e746b02196b7_s.jpg\",\"creator\":\"性能测试\",\"creatorId\":\"7a8c70eefde44410b9a7f771250f75a8\",\"format\":\"jpg\",\"height\":1067,\"id\":\"d7873127ad35425098190112c232a965\",\"size\":525263,\"title\":\"92866e8d33d045b69a971420a4ff7a0b.jpg\",\"type\":1,\"url\":\"https://app-newstest.ceic.com/mam/material/mam/uploadTemp/f87d033e870849e48103e746b02196b7.jpg\",\"width\":1600},{\"converImg\":\"https://app-newstest.ceic.com/mam/material/mam/uploadTemp/558828a6219949b694abd10b7c055661_s.jpg\",\"creator\":\"性能测试\",\"creatorId\":\"7a8c70eefde44410b9a7f771250f75a8\",\"format\":\"jpg\",\"height\":1067,\"id\":\"d8cde8e89fee424699772b17c9f930dc\",\"size\":525263,\"title\":\"92866e8d33d045b69a971420a4ff7a0b.jpg\",\"type\":1,\"url\":\"https://app-newstest.ceic.com/mam/material/mam/uploadTemp/558828a6219949b694abd10b7c055661.jpg\",\"width\":1600},{\"converImg\":\"https://app-newstest.ceic.com/mam/material/mam/uploadTemp/6010f06887ca4ae1b38095ce3405a854_s.jpg\",\"creator\":\"性能测试\",\"creatorId\":\"7a8c70eefde44410b9a7f771250f75a8\",\"format\":\"jpg\",\"height\":1067,\"id\":\"cbd9a28c97934462aa10a9f667546b4e\",\"size\":525263,\"title\":\"92866e8d33d045b69a971420a4ff7a0b.jpg\",\"type\":1,\"url\":\"https://app-newstest.ceic.com/mam/material/mam/uploadTemp/6010f06887ca4ae1b38095ce3405a854.jpg\",\"width\":1600},{\"converImg\":\"https://app-newstest.ceic.com/mam/material/mam/uploadTemp/d129bfaa27cf4784b3e5f09eae598b6a_s.jpg\",\"creator\":\"性能测试\",\"creatorId\":\"7a8c70eefde44410b9a7f771250f75a8\",\"format\":\"jpg\",\"height\":1067,\"id\":\"d69a93f9abcd4b499b24fc5aa69c2fce\",\"size\":525263,\"title\":\"92866e8d33d045b69a971420a4ff7a0b.jpg\",\"type\":1,\"url\":\"https://app-newstest.ceic.com/mam/material/mam/uploadTemp/d129bfaa27cf4784b3e5f09eae598b6a.jpg\",\"width\":1600},{\"converImg\":\"https://app-newstest.ceic.com/mam/material/mam/uploadTemp/59985eec51ef483ca26cba1679021c19_s.jpg\",\"creator\":\"性能测试\",\"creatorId\":\"7a8c70eefde44410b9a7f771250f75a8\",\"format\":\"jpg\",\"height\":1067,\"id\":\"0d62ce3f8d614ecabd1d8ba48981fa9a\",\"size\":525263,\"title\":\"92866e8d33d045b69a971420a4ff7a0b.jpg\",\"type\":1,\"url\":\"https://app-newstest.ceic.com/mam/material/mam/uploadTemp/59985eec51ef483ca26cba1679021c19.jpg\",\"width\":1600},{\"converImg\":\"https://app-newstest.ceic.com/mam/material/mam/uploadTemp/e5c50b7e88e34f2ea7a1aa1a063e8ba5_s.jpg\",\"creator\":\"性能测试\",\"creatorId\":\"7a8c70eefde44410b9a7f771250f75a8\",\"format\":\"jpg\",\"height\":1067,\"id\":\"8874004339dd471aa308713cd758e988\",\"size\":525263,\"title\":\"92866e8d33d045b69a971420a4ff7a0b.jpg\",\"type\":1,\"url\":\"https://app-newstest.ceic.com/mam/material/mam/uploadTemp/e5c50b7e88e34f2ea7a1aa1a063e8ba5.jpg\",\"width\":1600}],\"status\":200}";
        String json2 = JSON.toJSONString(json);
        JSONObject jsonObject = JSON.parseObject(json);
//        System.out.println(jsonObject);

        VideoProcessParam videoProcessParam = new VideoProcessParam();
        videoProcessParam.setSourceId("111");
        JxrbVideoProcessParam js = new JxrbVideoProcessParam();
        js.setTenantId("222");
        js.setThirdCode("jxrb");
        String s1 = JsonUtil.toJson(videoProcessParam);
        String s2 = JsonUtil.toJson(js);

        System.out.println(s1);
        System.out.println(s2);
        JxrbVideoProcessParam baseParam =  JsonUtil.fromJson(s2, JxrbVideoProcessParam.class);
        if (baseParam instanceof JxrbVideoProcessParam) {
            System.out.println("我是江西日报1");
        }
        if (StringUtils.isNotBlank(baseParam.getThirdCode()) && baseParam.getThirdCode().equals("jxrb")) {
            System.out.println("我是江西日报2");
        }

    }
}
